package org.jieshen.m1.d7;

import java.util.Stack;

public class Solution {
    public int maxDepth(String s) {
        Stack<Character> stack = new Stack<>();
        int maxHeight = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '(') {
                stack.add('(');
                if (maxHeight < stack.size())
                    maxHeight = stack.size();
            } else if (c == ')') {
                stack.pop();
            }
        }
        return maxHeight;
    }

    public static void main(String[] args) {
        String s = "1";
        //输出：3
        System.out.println(new Solution().maxDepth(s));
    }
}
